{extend name="layouts:form"/}

{block name="css_common"}
    {asset:css name="summernote" /}
{/block}
{block name="js_common"}
    {asset:js name="summernote" /}
{/block}

{block name="content"}
<form class="form-horizontal m" id="form-add">
    <div class="form-group">
        <label class="col-sm-2 control-label is-required">公告标题：</label>
        <div class="col-sm-9">
            <input type="text" name="title" value="" class="form-control" placeholder="请输入公告标题" required autocomplete="off"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label is-required">公告内容：</label>
        <div class="col-sm-9">
            <textarea id="content" name="content" class="hide" required></textarea>
            <div class="summernote" data-place="请输入公告内容" id="contentEditor"></div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label is-required">状态：</label>
        <div class="col-sm-9">
            <label class="radio-box"><input type="radio" name="status" value="0"/> 无效</label>
            <label class="radio-box"><input type="radio" name="status" value="1" checked/> 有效</label>
        </div>
    </div>

    <div class="row m-t-md">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
</form>
{/block}

{block name="script"}
    <script>
        function submitHandler() {
            if ($.validate.form()) {
                if($("#contentEditor").summernote('isEmpty')){
                    $.modal.msgError('请填写内容')
                    return false;
                }
                var sHTML = $('#contentEditor').summernote('code');
                $("#content").val(sHTML);
                $.operate.saveTab(oasUrl, $('#form-add').serialize());
            }
        }
    </script>
{/block}
